<?php

define('DEBUG_STATE', FALSE);

/******************************************************
 *			  READ CONFIG FROM FILESYSTEM			  *
 ******************************************************/

require(__DIR__.DIRECTORY_SEPARATOR.'constants.php');
require(__DIR__.DS.'config.php');

/******************************************************
 *				    SET INCLUDE PATHS				  *
 ******************************************************/

$include_paths= array_filter(array(
	$_CONFIG->site_path.'engine'.DS.'lib'.DS,
	$_CONFIG->site_path.'engine'.DS.'classes'.DS
));

/******************************************************
 *				 INCLUDE CLASES AND LIBS			  * 
 ******************************************************/

foreach($include_paths as $path){
	foreach (glob($path.'*.php') as $filename){
	    require_once $filename;
	}	
}

/******************************************************
 *				 	   DATABASE						  * 
 ******************************************************/

$_DB= new BlgDB();
$_DB->connect();

/******************************************************
 *				  READ CONFIG FROM DB				  *
 ******************************************************/

blg_load_db_config();

/******************************************************
 *				 		SESSION						  * 
 ******************************************************/

blg_session_start();

/******************************************************
 *					 LOAD LANGUAGES					  * 
 ******************************************************/

$_LANG= blg_get_lang();

/******************************************************
 *				   		  CACHE			  	  		  * 
 ******************************************************/

$_CACHE= new BlgCache(blg_get_config('cache_dir'));

/******************************************************
 *				   JS, CSS, MENU STACKS			  	  * 
 ******************************************************/

$_CSS_STACK= new blgViewsStack('css');
$_JS_STACK = new blgViewsStack('js');
$_JS_CODE= new BlgJSStack();

$_MENU= new BlgMenu();

/******************************************************
 *				   LOAD DEFAULT VIEWS			  	  * 
 ******************************************************/

$_VIEWS= new blgViewsRegister();
$_COLORS= array();	
blg_register_views();

/******************************************************
 *					   LOAD ACTIONS					  * 
 ******************************************************/

blg_register_actions();

/******************************************************
 *					  LOAD MODULES				  	  * 
 ******************************************************/

blg_register_mod('error');
blg_register_mod('phpmailer');
blg_register_mod('ui-jquery');
//blg_register_mod('min'); 		//Minify 2.15
blg_register_mod('gdata'); 		//Zend GData (Google API)

/******************************************************
 *					  LOAD PAGES				  	  * 
 ******************************************************/

blg_register_pages();

